import React, { useState } from 'react'
import { generateRandomColor } from '../../../utils/tool';

export default function ChangeBg() {
  //声明状态
  let [color, setColor] = useState('#000');
  let [color2, setColor2] = useState('#123');

  //声明函数
  let changeBG = () => {
    //更新颜色的状态值
    setColor(generateRandomColor());
  }

  return (
    <div onClick={changeBG} style={{width: 300, height: 200, margin: "100px auto", border: 'solid 1px #89a', backgroundColor: color}}>

    </div>
  )
}
